<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <table>
        <thead>
            <th>姓名</th>
            <th>年龄</th>
        </thead>
        <tbody>

        </tbody>
    </table>

    <script>

        var students = [
            {
                name: 'zs',
                age: 18,
            },
            {
                name: 'ls',
                age: 19,
            },
            {
                name: 'ww',
                age: 28,
            },
        ];

        var tbody = document.querySelector('tbody');

        for (var student of students) {
            // student: { name: 'zs', age: 18 }
            // 1. 创建tr 加到tbody
            var tr = document.createElement('tr');
            tbody.appendChild(tr);
            // 创建两个td
            var nameTd = document.createElement('td');
            var ageTd = document.createElement('td');
            tr.appendChild(nameTd);
            tr.appendChild(ageTd);
            // 给td加内容
            // 'zs': student.name
            // 18: student.age
            nameTd.innerText = student.name;
            ageTd.innerText = student.age;
        }

    </script>
</body>
</html>